{% extends "base/base.html" %}

{% comment %}

 Copyright 2013 - Tom Alessi

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and 
 limitations under the License.

{% endcomment %}

{% block content %}

<br>

<div class="row">
  <div class="large-6 large-centered columns">
    <form method="POST" name="rm_services" id="rm_services" action="/rm_services">
    {% csrf_token %}

    <fieldset>
      <legend>Manage Services</legend>

      {% if services %}
      <table class="standard">
       <tr>
        <th>Delete</th>
        <th>Service Name</th>
       </tr>
          
       {% for row in services %}
       <tr>
        <td><input type="checkbox" name="id" value="{{row.id}}" /></td>
        <td>{{row.service_name}}</td>
       </tr>
       {% endfor %}
      </table>
      
      <input type="submit" class="small button" value="delete"/>
      {% if form.id.errors %}
        <p class="error">{% for error in form.id.errors %}{{error}}{% endfor %}</p>
      {% endif %}
    </form>
    
    {% else %}
    No services defined
    {% endif %}
    </fieldset>
    </form>
  </div>
</div>
  

<div class="row">
  <div class="large-6 large-centered columns">

    <form method="POST" name="manage_services" id="manage_services" action="/services">
     {% csrf_token %}

    <fieldset>
      <legend>Add Service</legend>

      <div class="row">
        <div class="large-6 columns">
         <label>Service Name</label>
        </div>
      </div>

      <div class="row">
        <div class="large-12 columns {% if form.service.errors %}error{% endif %}">
          <input name="service" type="text" placeholder="Enter a service name" value="{% if form.service.data %}{{form.service.data}}{% endif %}">
          {% if form.service.errors %}
          <small class="error">
            {% for error in form.service.errors %}{{error}}{% endfor %}
          </small>
          {% endif %}
        </div>
      </div>

      <div class="row">
        <div class="large-12 columns">
          <input type="submit" class="small button" value="add"/>
        </div>
      </div>

      </fieldset>
    </form> 
  </div>
</div>

{% endblock %}
